<?php
/**
 * View_Direction
 *
 * Класс View_Direction отвечает за вывод информации, связанной со страницами "Наши направления"
 *
 */
class View_Direction extends View_Base {
	
	/**
	 * (non-PHPdoc)
	 * @see View_Base::showOneInList()
	 */
	public function showOneInAdminList(&$arrFederalDistrict) {
		Service_Debug::setDebug();
		echo '<p>';
			echo '<a class="fo-link" fo-id="' . $arrFederalDistrict['ID_federal_district'] . '" href="' . W_ABSPATH . $arrFederalDistrict['federal_district_url'] . '">' . $arrFederalDistrict['federal_district_name'] . '</a>';
		echo '</p>';
	}
	
	/**
	 * Метод отображает список федеральных окргуов
	 *
	 * @param array $arrFederalDistricts - массив ФО
	 */
	public function showAdminList($arrFederalDistricts,$beforeContetntText) {
		Service_Debug::setDebug();
		echo '<div class="content-container padd">';
			echo '<div class="before-c-text">';
				echo $beforeContetntText;
			echo '</div>';
			
			echo '<div class="c-list fo-list">';
				foreach ($arrFederalDistricts as $arrFederalDistrict) {
					$this->showOneInAdminList($arrFederalDistrict);
				}
			echo '</div>';
			
			echo '<div id="fo-map-pic">';
				echo '<img src="/content/images/fo-map.png" usemap="#fo-map">';
				echo '<img src="/content/images/fo-map-1.png" usemap="#fo-map">';
				echo '<img src="/content/images/fo-map-2.png" usemap="#fo-map">';
				echo '<img src="/content/images/fo-map-3.png" usemap="#fo-map">';
				echo '<img src="/content/images/fo-map-4.png" usemap="#fo-map">';
				echo '<img src="/content/images/fo-map-5.png" usemap="#fo-map">';
				echo '<img src="/content/images/fo-map-6.png" usemap="#fo-map">';
				echo '<img src="/content/images/fo-map-7.png" usemap="#fo-map">';
				echo '<img src="/content/images/fo-map-8.png" usemap="#fo-map">';
			echo '</div>';
			
			echo '<map name="fo-map" id="fo-map">';
				echo '<area shape="poly" alt="s" fo-id="1" href="' . W_ABSPATH . 'tsfo"  coords="30,121,28,114,30,109,33,104,28,99,31,93,36,94,40,89,41,85,47,81,51,81,55,82,60,84,65,85,69,87,73,89,77,92,80,94,84,99,87,101,90,103,94,106,97,109,96,111,86,110,79,111,77,112,73,115,70,117,67,120,61,122,58,127,55,130,50,133,47,135,42,135,37,135,35,131,32,127,31,123">';			
				echo '<area shape="poly" alt="s" fo-id="2" href="' . W_ABSPATH . 'yufo" coords="1,142,6,138,12,136,19,136,23,136,28,137,33,136,21,136,49,136,53,136,55,140,55,148,55,154,56,157,54,159,49,160,48,162,48,166,49,171,49,175,46,177,44,181,39,178,34,180,31,180,30,175,28,173,27,163,26,159,22,154,19,154,17,155,16,157,13,162,9,161,6,162,3,159,4,151,2,142">';
				echo '<area shape="poly" alt="s" fo-id="3" href="' . W_ABSPATH . 'szfo" coords="51,81,55,82,60,83,65,84,72,87,79,91,82,94,85,100,91,103,95,105,100,110,104,113,105,113,111,115,115,118,120,118,124,118,127,120,131,122,137,123,142,125,147,125,150,121,156,116,161,113,167,111,174,109,182,105,184,102,186,95,183,88,179,82,178,74,181,69,184,65,193,63,203,61,213,59,218,56,216,51,208,50,198,50,189,52,180,54,172,60,167,64,167,70,170,76,165,83,161,77,159,68,148,66,140,64,137,58,137,51,136,46,135,40,128,37,122,36,114,41,109,45,106,48,100,52,94,54,92,60,83,61,74,61,70,63,63,62,39,44,30,42,38,72,48,75,48,79">';
				echo '<area shape="poly" alt="s" fo-id="4" href="' . W_ABSPATH . 'dfo" coords="413,15,420,19,435,13,442,5,453,13,447,23,446,31,452,34,459,39,457,51,460,69,455,79,452,90,460,100,457,133,447,133,444,109,441,91,431,95,432,111,421,123,403,136,400,171,419,167,427,162,444,179,448,191,457,199,451,205,433,185,438,198,437,229,426,245,413,241,417,228,414,213,399,219,383,214,371,202,355,203,347,191,339,180,326,169,317,166,305,174,298,165,295,153,289,142,281,130,285,115,289,107,292,95,289,86,302,83,314,83,322,79,330,87,340,83,346,69,362,65,380,55,394,55,407,43,402,35,415,23,416,19">';
				echo '<area shape="poly" alt="s" fo-id="5" href="' . W_ABSPATH . 'sfo" coords="231,86,233,82,236,77,243,71,253,67,262,63,268,57,273,61,283,63,288,71,282,79,279,83,284,86,294,94,286,100,287,107,282,115,277,126,280,133,281,140,289,146,293,159,293,167,300,173,305,170,313,163,321,167,330,174,337,184,344,188,345,198,342,204,343,214,343,223,336,225,326,227,318,231,308,236,297,235,287,231,277,230,269,227,264,222,256,223,253,227,255,231,243,233,235,231,231,228,222,234,208,234,202,225,197,219,185,213,182,215,180,205,175,200,169,189,173,191,156,185,154,182,157,178,161,171,170,164,187,163,197,155,212,161,220,152,223,139,218,128,220,121,217,109,220,101,225,92,229,92,224,89,226,86,225,80">';
				echo '<area shape="poly" alt="s" fo-id="6" href="' . W_ABSPATH . 'ufo" coords="156,175,122,172,122,167,123,155,136,142,145,132,151,124,158,117,167,113,177,109,181,104,184,101,192,103,190,96,194,91,199,84,204,81,208,82,212,85,216,89,222,95,215,106,218,111,217,119,219,131,222,140,220,146,216,153,215,158,205,156,196,156,186,158,172,162,161,164">';
				echo '<area shape="poly" alt="s" fo-id="7" href="' . W_ABSPATH . 'pfo" coords="55,155,55,150,54,146,54,143,57,141,54,138,51,134,55,132,59,128,61,125,65,121,69,118,75,116,80,113,84,112,89,113,95,114,99,114,102,111,108,114,111,116,116,117,122,116,126,118,130,121,135,121,141,124,143,125,145,130,143,130,142,135,141,136,139,136,136,141,134,142,129,146,124,150,118,152,118,159,124,165,114,161,112,167,115,163,118,172,120,171,120,175,120,177,115,176,112,178,111,180,112,184,110,186,108,187,103,186,101,184,96,181,88,176,61,159,64,158,84,172,80,161">';
				echo '<area shape="poly" alt="s" fo-id="8" href="' . W_ABSPATH . 'skfo" coords="5, 162, 9, 160, 11, 163, 14, 159, 16, 154, 17, 154, 19, 153, 22, 156, 21, 154, 25, 158, 26, 162, 26, 165, 27, 169, 27, 173, 29, 176, 30, 177,30, 180, 30, 184, 28, 186, 27, 191, 25, 192, 25, 194, 25, 197, 24, 200, 21, 200, 17, 198, 15, 195, 15, 190, 14, 187, 12, 180, 10, 177, 7, 169, 4, 164, 5, 162">';
			echo '</map>';
		echo '</div>';
	}
	
	/**
	 * Метод отображает главную страницу Федерального округа
	 * 
	 * @param FederalDistrict $objFederalDistrict
	 */
	public function showFederalDistrictPage($objFederalDistrict, $regionsArray, $citiesArray) {
		Service_Debug::setDebug();
		echo '<div class="content-container padd">';
			echo '<h1>Грузоперевозки ' . Service_Declination::getGenitive($objFederalDistrict->getField('federal_district_name')) . '</h1>';
			
			echo '<div class="r-list bld">';
			echo '<h2>Регионы</h2>';
			foreach($regionsArray as $regionArray) {
				echo '<p>';
				echo '<a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '/' . $regionArray['region_url']. '">' . $regionArray['region_name'] . '</a>';
				echo '</p>';
			}
			echo '</div>';
			
			echo '<div class="c-list">';
				echo '<h2>Популярные города</h2>';
				//echo '<div class="cities-list">';
				$citiesCount = count($citiesArray);
				for ($i = 0; $i < $citiesCount; $i++) {
					if($i == 0) echo '<div class="pop-city-bl">';
					echo '<p>';
						echo '<a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '/' . $citiesArray[$i]['city_url'] . '">' . $citiesArray[$i]['city_name'] . '</a>';
					echo '</p>';
					if(!(($i + 1) % 10) && $i != ($citiesCount - 1)) echo '</div><div class="pop-city-bl">';
					elseif(!(($i + 1) % 10) || $i == ($citiesCount - 1))  echo '</div>';
			}
				//echo '<div class="clear"></div>';
				//foreach ($citiesArray as $cityArray) {
				//	echo '<p>';
				//		echo '<a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '/' . $cityArray['city_url'] . '">' . $cityArray['city_name'] . '</a>';
				//	echo '</p>';
				//}
				echo '<a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '/cities" class="more-link">Все города ' . Service_Declination::getGenitive($objFederalDistrict->getField('federal_district_name')) . '</a>';
			echo '</div>';
			
			
			$this->showFastOrderBlock();
		echo '</div>';
	}
	
	/**
	 * Метод отображает страницу всех городов Федерального округа
	 *  
	 * @param FederalDistrict $objFederalDistrict
	 * @param array $citiesArray - массив городов
	 */
	public function showFederalDistrictCities($objFederalDistrict,$citiesArray) {
		Service_Debug::setDebug();
		echo '<div class="content-container padd">';
			echo '<h1>Грузопревозки в городах ' . Service_Declination::getGenitive($objFederalDistrict->getField('federal_district_name'))   . '</h1>';
			echo '<div class="cities-list">';
				$itemsInBlock = ceil(count($citiesArray) / 6);
				$wordLineHeight = 22;
				$cityLineHeight = 22;
				$i = 0;
				$wordsCount = 0;
				$lastWord = '';
				$last = 0;
				$height = 0;
				$limit = $itemsInBlock * $cityLineHeight + $wordLineHeight * 5;
				echo '<div class="block">';
				foreach($citiesArray as $cityArray) {
					$currentWord = mb_substr($cityArray['city_name'], 0, 1, 'utf8');
					if($height >= $limit || ($currentWord != $lastWord && ($height + $wordLineHeight) >= $limit)) {
						echo '</div>';
						echo '<div class="block">';
						$wordsCount = 0;
						$i = 0;
						$height = 0;
					}
					if($currentWord != $lastWord) {
						echo '<h2>' . $currentWord . '</h2>';
						$lastWord = $currentWord;
						$wordsCount++;
						$height += $wordLineHeight;
					}
					echo '<p>';
						echo '<a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '/' . $cityArray['city_url'] . '"' . ($cityArray['city_type'] > 3 ? ' class="bld"' : '') . '>' . $cityArray['city_name'] . '</a>';
					echo '</p>';
					$height += $cityLineHeight;
					$i++;
				}
				echo '</div>';
			echo '</div>';
		echo '</div>';
	}
	
	/**
	 * Метод отображает страницу города
	 * 
	 * @param City $objCity - объект города
	 */
	public function showCityPage($objCity, FederalDistrict $objFederalDistrict) {
		Service_Debug::setDebug();

		echo '<div class="content-container padd">';
			echo '<div class="top-info">';
				echo '<div class="city-regions">';
					echo '<h1>Грузоперевозки ' . Service_Declination::getGenitive($objCity->getField('city_name')) . '</h1>';
					$regionArray = $objCity->getRegion();
					echo '<span class="region"><a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '/' . $regionArray['region_url'] . '">' . $regionArray['region_name'] . '</a></span>';
					echo '<h3><a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '">' .  $objFederalDistrict->getField('federal_district_name') . '</a></h3>';
				echo '</div>';
				echo '<div class="symbols">';
					echo '<table><tr>';
						if($objCity->getField('arms_url'))echo '<td class="arms"><img src="' . $objCity->getField('arms_url') . '"></td>';
						if($objCity->getField('flag_url'))echo '<td class="flag"><img src="' . $objCity->getField('flag_url') . '"></td>';
					echo '</tr></table>';
				echo '</div>';
				echo '<div class="city-text">';
					if($objCity->getField('ID_federal_district') == 3) {
						echo Service_TextMaker::getCityFirstP($objCity);
						echo Service_TextMaker::getCitySecondP($objCity);
						echo Service_TextMaker::getCityThirdP($objCity);
						echo Service_TextMaker::getCityFourthP($objCity);
						echo Service_TextMaker::getCityFifthP($objCity);
						echo Service_TextMaker::getCitySixthP($objCity);
						echo Service_TextMaker::getCitySeventhP($objCity);
						echo Service_TextMaker::getCityEighthP($objCity);
						echo Service_TextMaker::getCityNinthP($objCity);
					}
				echo '</div>';
			echo '</div>';
			
			echo '<div class="middle-block">';
				echo '<div id="map-canvas"></div>';
			echo '</div>';
			
			$arrData = array(
					'latitude' => $objCity->getField('latitude'),
					'longitude' => $objCity->getField('longitude')
					);
			echo '<div data-position=\'' . json_encode($arrData) . '\' id="map-data"></div>';
			
			$this->showFastOrderBlock();
			
			$arrMainCities = $objCity->getPopularCities();		// Получаем смежные города для текущего города
			echo '<div class="bottom-info">';
				echo '<h2>Популярные направления</h2>';
				$citiesCount = count($arrMainCities);
				for ($i = 0; $i < $citiesCount; $i++) {
					if($i == 0) echo '<div class="pop-city-bl">';
					echo '<p>';
						echo '<a href="' . W_ABSPATH . $arrMainCities[$i]['federal_district_url'] . '/' . $arrMainCities[$i]['city_url'] . '">' . $arrMainCities[$i]['city_name'] . '</a>';
					echo '</p>';
					if(!(($i + 1) % 6) && $i != ($citiesCount - 1)) echo '</div><div class="pop-city-bl">';
					elseif(!(($i + 1) % 6))  echo '</div>';
				}
				echo '<div class="clear"></div>';
			echo '</div>';
		echo '</div>';
	}
	
	/**
	 * Метод отображает страницу региона
	 *
	 * @param Region $objRegion - объект города
	 * @param FederalDistrict $objFederalDistrict - объект федерального округа
	 */
	public function showRegionPage($objRegion, $objFederalDistrict) {
		echo '<div class="content-container padd">';
			echo '<div class="top-info">';
				echo '<div class="city-regions">';
					echo '<h1>Грузоперевозки ' . Service_Declination::getGenitive($objRegion->getField('region_name')) . '</h1>';
					echo '<h3><a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '">' .  $objFederalDistrict->getField('federal_district_name') . '</a></h3>';
				echo '</div>';
				echo '<div class="symbols">';
					echo '<table><tr>';
						if($objRegion->getField('arms_url'))echo '<td class="arms"><img src="' . $objRegion->getField('arms_url') . '"></td>';
						if($objRegion->getField('flag_url'))echo '<td class="flag"><img src="' . $objRegion->getField('flag_url') . '"></td>';
					echo '</tr></table>';
				echo '</div>';
				echo '</div>';
		/*echo '<div class="city-text">';
		echo $this->getOneCityFirstP($objCity);
		echo '</div>';
		echo '</div>';
			
		echo '<div class="middle-block">';
		echo '<div id="map-canvas"></div>';
		echo '</div>';
			
		$arrData = array(
				'latitude' => $objCity->getField('latitude'),
				'longitude' => $objCity->getField('longitude')
		);
		echo '<div data-position=\'' . json_encode($arrData) . '\' id="map-data"></div>';
			
		$this->showFastOrderBlock();
			
		$arrMainCities = $objFederalDistrict->getMainCities($objCity->id);		// Получаем смежные города для текущего города
		echo '<div class="bottom-info">';
		echo '<h2>Популярные направления</h2>';
		$citiesCount = count($arrMainCities);
		for ($i = 0; $i < $citiesCount; $i++) {
			if($i == 0) echo '<div class="pop-city-bl">';
			echo '<p>';
			echo '<a href="' . W_ABSPATH . $objFederalDistrict->getField('federal_district_url') . '/' . $arrMainCities[$i]['city_url'] . '">' . $arrMainCities[$i]['city_name'] . '</a>';
			echo '</p>';
			if(!(($i + 1) % 4) && $i != ($citiesCount - 1)) echo '</div><div class="pop-city-bl">';
			elseif(!(($i + 1) % 4))  echo '</div>';
		}
		echo '<div class="clear"></div>';
		echo '</div>';
		*/
		echo '</div>';
	}
	
	/**
	 * Метод отображает страницу маршрута
	 *
	 * @param array $routeArray - массив отрезков
	 * @param array $citiesArray - массив двух городов маршрута
	 */
	public function showRoutePage($routeArray, $citiesArray) {
		Service_Debug::setDebug();														
		$popRoutesArray = Route::getPopularRoutes($citiesArray);							// Массив похожих маршрутов
		$citiesCount = count($popRoutesArray);
		$totalDistance = 0;
		foreach ($routeArray as $arrRoutePart) $totalDistance += $arrRoutePart['distance_to_next'];

		echo '<div class="content-container padd">';
			echo '<div data-markers=\'' . json_encode($routeArray) . '\' id="map-data"></div>';
			echo '<div class="top-info">';
				echo '<h1>Грузоперевозки ' . $citiesArray[0]['city_name'] . ' - ' . $citiesArray[1]['city_name'] . '</h1>';
				echo Service_TextMaker::getRouteFirstP($citiesArray[0], $citiesArray[1], $totalDistance);
				echo Service_TextMaker::getRouteSecondP($citiesArray[0], $citiesArray[1]);
				echo Service_TextMaker::getRouteThirdP($citiesArray[0], $citiesArray[1]);
				echo Service_TextMaker::getRouteFourthP($citiesArray[0], $citiesArray[1]);
			echo '</div>';
			
			echo '<div class="middle-block">';
				echo '<div id="map-canvas"></div>';
			echo '</div>';
			$this->showFastOrderBlock($citiesArray[0]['city_name'], $citiesArray[1]['city_name']);
			
			$wayLength = 0;
			// Блок разбивки маршрута
			echo '<table class="essence-list route-description">';
				echo '<tr>';
					echo '<td>';
						echo 'Город';
					echo '</td>';
					echo '<td>';
						echo 'Длина отрезка';
					echo '</td>';
					echo '<td>';
						echo 'Длина пути';
					echo '</td>';
				echo '</tr>';
				foreach ($routeArray as $key => $distanceArray) {
					echo '<tr class="item">';
						echo '<td>';
							if($key != 0) {
								echo '<div class="road-type-' . $routeArray[$key - 1]['road_type'] . '"></div>';
							}
							echo '<div class="city-description">';
								echo '<div class="city-type-' . $distanceArray['city_type'] . '"></div>';
								echo $distanceArray['city_name'];
							echo '</div>';
						echo '</td>';
						echo '<td>';
							echo $key != 0 ? $routeArray[$key - 1]['distance_to_next'] . ' км' : '';
						echo '</td>';
						echo '<td>';
							if($key != 0) {
								$wayLength += $routeArray[$key - 1]['distance_to_next'];
								echo $wayLength . ' км';
							}
						echo '</td>';
					echo '</tr>';
				}
				
			echo '</table>';
			
			echo '<div class="bottom-info c-list">';
			echo '<h2>Похожие маршруты</h2>';
			
			// Если обе ключевые точки маршрута принадлежат одному ФО, то обрабатываем отдельно, т.к. возможно количетсо вмаршрутов меньше 14(если у ФО мало городов)
			if($citiesArray[0]['ID_federal_district'] == $citiesArray[1]['ID_federal_district']) {
				if($citiesCount % 2) unset($popRoutesArray[$citiesCount - 1]);	// сли число гроодов в массиве нечётное, то убираем последний город
				$routesCount = $citiesCount / 2;			// Число маршрутов
				$routesInBlock = ceil($routesCount / 2);	// Максимальное число маршрутов в блоке. Используется, чтобы для ФО с маленьким числом городов кол-во маршрутов в блоках было одинаково
				for($i = 0; $i < $routesCount; $i++) {
					if($i == 0 || $i == $routesInBlock) echo '<div class="pop-route-bl">';
					echo '<p>';
					echo '<a href="' . W_ABSPATH . 'routes/' . $popRoutesArray[$i]['city_url'] . '-' . $popRoutesArray[$i + $routesCount]['city_url'] . '">' . $popRoutesArray[$i]['city_name'] . ' - ' . $popRoutesArray[$i + $routesCount]['city_name'] . '</a>';
					echo '</p>';
					if($i == ($routesInBlock - 1) || $i == ($routesCount - 1)) echo '</div>';
				}
			}
			else {
				for($i = 0; $i < $citiesCount; $i++) {
					if($i == 0 || $i == 14) echo '<div class="pop-route-bl">';
					echo '<p>';
					echo '<a href="' . W_ABSPATH . 'routes/' . $popRoutesArray[$i]['city_url'] . '-' . $popRoutesArray[$i + 7]['city_url'] . '">' . $popRoutesArray[$i]['city_name'] . ' - ' . $popRoutesArray[$i + 7]['city_name'] . '</a>';
					echo '</p>';
					if($i == 6 || $i == 20) {
						echo '</div>';
						$i += 7;
					}
				}
			}
			echo '<div class="clear"></div>';
			echo '</div>';
			
		echo '</div>';
		
	}
	
	public function showFastOrderBlock($from = null, $to = null) {
		echo '<div class="fast-order full-border">';
			echo '<div class="left-part">';
				echo '<p>БЫСТРЫЙ ЗАКАЗ</p><p>НА ДОСТАВКУ ГРУЗА</p>';
					echo '<div class="instructions">';
						echo 'Оставьте информацию о заказе и наш сотрудник Вам позвонит.';
					echo '</div>';
				echo '</div>';
			echo '<div class="right-part">';
				$objForm = new Form_ViewForm(array(
						'viewFormType' => 'div',
						'id' => 'fast-order',
						'leftWidth' => 320
				), new Order);
				$objForm->show();
				echo '<div class="fields">';
					$objForm->textField(array('text' => 'Откуда', 'value' => $from ? $from : '', 'class' => 'city-field'), 'city_from_string');
					$objForm->hiddenField(array('class' => 'ID_city'), 'city_from');
						
					$objForm->textField(array('text' => 'Куда', 'value' => $to ? $to : '', 'class' => 'city-field'), 'city_to_string');
					$objForm->hiddenField(array('class' => 'ID_city'), 'city_to');
						
					$objForm->textField(array('text' => 'Телефон', 'class' => 'phone mandatory'), 'one_phone');
						
					$objForm->textField(array('text' => 'Тип груза', 'min' => 2, 'maxlength' => '1024','class' => 'mandatory'), 'description');
				echo '</div>';
				echo '<div id="box-picture"></div>';
				$objForm->submitButton(array('value' => 'Отправить'), 'save');
				$objForm->close();
			echo '</div>';
		echo '</div>';
	}
	
	/**
	 * Формирует тайтл страницы конкретного города
	 *
	 * @param City $objCity - объект города
	 * @return string
	 */
	public function getOneCityTitle(City $objCity) {
		Service_Debug::setDebug();
		$cityName = $objCity->getField('city_name');
		$cityNameGenetive = Service_Declination::getGenitive($cityName);
		switch ($objCity->id % 4) {
			case 0: return 'Грузоперевозки ' . $cityNameGenetive . '. Междугородние грузоперевозки в/из ' . $cityName . '.';
			case 1: return 'Грузоперевозки ' . $cityNameGenetive . '. Цены на грузоперевозке в городе ' . $cityName;
			case 2: return $cityName . ' - грузоперевозки. Междугородние грузоперевозки ' . $cityNameGenetive . '.';
			case 3: return $cityName . ' - грузоперевозки. Цены на грузоперевозки ' . $cityNameGenetive;
		}
	}
	
	/**
	 * Формирует тайтл страницы маршрута
	 *
	 * @param array $cityArrFrom - массив города A
	 * @return array $cityArrTo - массив города B
	 */
	public function getRouteTitle(&$cityArrFrom, &$cityArrTo) {
		Service_Debug::setDebug();
		
		switch (($cityArrFrom['ID_city'] + $cityArrTo['ID_city']) % 4) {
			case 0: return 'Грузоперевозки по маршруту ' . $cityArrFrom['city_name'] . '-' . $cityArrTo['city_name'] . '.';
			case 1: return 'Грузоперевозки по направлению ' . $cityArrFrom['city_name'] . '-' . $cityArrTo['city_name'] . ' и обратно.';
			case 2: return 'Маршрут ' . $cityArrFrom['city_name'] . '-' . $cityArrTo['city_name'] . ' - грузоперевозки, цены, описание.';
			case 3: return 'Грузоперевозки ' . $cityArrFrom['city_name'] . '-' . $cityArrTo['city_name'] . '. Проложить маршрут на карте.';
		}
	}
	
	/**
	 * Страница поиска информации по маршрутам(для админов)
	 *
	 */
	public function showRouteSearch() {
		Service_Debug::setDebug();
		echo '<form id="s-route">';
			echo '<div class="point">';
				echo 'Откуда: <input type="text" class="city-field from">';
				echo '<input type=hidden class="from-id">';
			echo '</div>';
			echo '<div class="point">';
				echo 'Куда: <input type="text" class="city-field to">';
				echo '<input type=hidden class="to-id">';
			echo '</div>';
			echo '<button type="submit">Поиск</button>';
		echo '</form>';
		
			echo '<div id="map-canvas"></div>';
			echo '<div class="results">';
				echo '<div class="desc"></div>';
				echo '<div class="wrap">';
					echo '<div class="type_handler">';
						echo '<div class="same">АНАЛОГИЧНЫЕ</div>';
						echo '<div class="like">ПОХОЖИЕ</div>';
					echo '</div>';
					echo '<div class="orders"></div>';
				echo '</div>';
			echo '</div>';	
	}
	
	/**
	 * Страница поиска информации по маршрутам(для админов)
	 *
	 */
	public function showRouteStat(&$statArr) {
		Service_Debug::setDebug();
		echo '<table class="stat">';
			echo '<tr>';
				echo '<td>Категория</td>';
				echo '<td>Количество заказов</td>';
				echo '<td>Минимальная стоимость заказа</td>';
				echo '<td>Максимальная стоимость заказа</td>';
				echo '<td>Средняя стоимость заказа</td>';
				echo '<td>Минимальная цена за километр</td>';
				echo '<td>Максимальная цена за километр</td>';
				echo '<td>Средняя цена за километр</td>';
			echo '</tr>';
			foreach ($statArr as $groupStatArr) {
				echo '<tr class="item">';
					echo '<td>';
						if($groupStatArr['distance'] <= 100) echo '... - 100';
						elseif($groupStatArr['distance'] <= 300) echo '101 - 300';
						elseif($groupStatArr['distance'] <= 500) echo '301 - 500';
						elseif($groupStatArr['distance'] <= 1000) echo '501 - 1000';
						elseif($groupStatArr['distance'] <= 2000) echo '1001 - 2000';
						elseif($groupStatArr['distance'] > 2000) echo '2000 - ...';
					echo '</td>';
					echo '<td>';
						echo $groupStatArr['count'];
					echo '</td>';
					echo '<td>';
						echo $groupStatArr['min_price'];
					echo '</td>';
					echo '<td>';
						echo $groupStatArr['max_price'];
					echo '</td>';
					echo '<td>';
						echo $groupStatArr['midd_price'];
					echo '</td>';
					echo '<td>';
						echo $groupStatArr['min_km_price'];
					echo '</td>';
					echo '<td>';
						echo $groupStatArr['max_km_price'];
					echo '</td>';
					echo '<td>';
						echo $groupStatArr['midd_km_price'];
					echo '</td>';
				echo '</tr>';
			}
		echo '</table>';
	}
	
}
?>